<?php

namespace App\Modules\Apicrzs\Http\Controllers\Intake;

use App\Modules\Apicrzs\Services\BaseServices;
use App\Modules\Apicrzs\Services\Water\WaterOrderService;
use Illuminate\Http\Request;

class WaterOrderController extends BaseServices
{

    public function __construct(WaterOrderService $service)
    {
        $this->service = $service;
    }


    /**
     * 扫码 下单 01
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function getIsOnline(Request $request)
    {
        $result = $this->service->getEquipmentIsOnline($request->all());
        if ($result){
            return $this->sendApiSuccess($result, $this->service->getError());
        }else{
            return $this->sendApiError($this->service->getError(),50001);
        }
    }


    /**
     * 扫码 下单 01
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function createScanStart(Request $request)
    {
        $result = $this->service->createScanOrder($request->all());
        if ($result){
            return $this->sendApiSuccess($result, $this->service->getError());
        }else{
            return $this->sendApiError($this->service->getError(),50001);
        }
    }

    /**
     *  扫码 支付 成功 02
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function paymentOrder(Request $request)
    {
        $result = $this->service->paymentOrder($request->all());
        if ($result){
            return $this->sendApiSuccess($result, $this->service->getError());
        }else{
            return $this->sendApiError($this->service->getError());
        }
    }
    /**
     *  扫码 支付 取消 02
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function paymentOrderCancel(Request $request)
    {
        $result = $this->service->paymentOrderCancel($request->all());
        if ($result){
            return $this->sendApiSuccess($result, $this->service->getError());
        }else{
            return $this->sendApiError($this->service->getError());
        }
    }

    /**
     * 扫码开始取水 03
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function getScanStart(Request $request)
    {
        $result = $this->service->getScanOnlineConsumeStart($request->all());
        if ($result){
            return $this->sendApiSuccess($result, $this->service->getError());
        }else{
            return $this->sendApiError($this->service->getError());
        }
    }
    /**
     * IC 卡  扫码取水 03
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function getScanConsumeStart(Request $request)
    {
        $result = $this->service->getScanConsume($request->all());
        if ($result){
            return $this->sendApiSuccess($result, $this->service->getError());
        }else{
            return $this->sendApiError($this->service->getError());
        }
    }

}
